import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class Main {
    public static User login(){//向上转型
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入姓名");
        String name = scanner.nextLine();
        System.out.println("请选择你的身份  -》1.管理员 -》2.用户");
        int choice  = scanner.nextInt();
        if(choice == 1){
            AdminUser adminUser = new AdminUser(name);
            return adminUser;
        }else{
            NormalUser normalUser = new NormalUser(name);
            return normalUser;
        }
    }
    public static void main(String[] args ) {
        BookList bookList =new BookList(10);
        User user = login();
        user.hello();//可以确定是那种用户
        while (true) {
            int choice = user.menu();//用户选择具体操作
            if(choice < 5) {
                user.doOperation(choice, bookList);//操作的执行
            }else{
                System.out.println("请重新输入");
            }
        }
    }
}